package com.lfd.rabbitmq.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

import java.nio.charset.StandardCharsets;

/**
 * @项目名： spring-emq
 * @包名： com.lfd.rabbitmq.service
 * @文件名: DirectMessageConsumer
 * @创建者: liufudong@szyh-smart.com
 * @创建时间: 2024/10/11 21:15
 * @描述：
 */
@Slf4j
@Service
public class DirectMessageConsumer {
    @RabbitListener(queues = "dead_letter_queue")
    public void handleDeadLetter(Message message) {
        String deadLetterMsg = new String(message.getBody(), StandardCharsets.UTF_8);
        log.info("接受DirectMessageConsumer Received dead letter message: {}", deadLetterMsg);
    }
}
